package com.twu.biblioteca;

public class BookCollection extends Collection {

    public static final String FORMAT = "%-40s%-40s%-20s";

    BookCollection(Book... books) {
        super(books);
    }

    @Override
    public String toString() {
        StringBuilder ret = new StringBuilder();

        if (items.size() == 0) {
            ret.append("No book in store").append("\n\n");
        } else {
            ret.append(String.format(FORMAT, "----", "------", "----"))
                .append("\n")
                .append(String.format(FORMAT, "name", "author", "year"))
                .append("\n")
                .append(String.format(FORMAT, "----", "------", "----"))
                .append("\n");
            for (Item book : items) {
                ret.append(book.toFormattedString(FORMAT));
            }
        }
        return ret.toString();
    }

}
